const AuthStepType = {
  ONE: 1, //未登录
  TWO: 2, //未授权
  THREE: 3, //以登录且授权
};

Component({
  options: {
    //开启自定义填充...略
    multipleSlots: true,
  },
  properties: {
    currAuthStep: {
      type: Number,
      value: AuthStepType.ONE,
    },
    userInfo: {
      type: Object,
      value: {},
    },
    isNeedGetUserInfo: {
      type: Boolean,
      value: false,
    },
  },
  data: {
    //默认图像
    defaultAvatarUrl: 'https://cdn-we-retail.ym.tencent.com/miniapp/usercenter/icon-user-center-avatar@2x.png',
    //登录状态标识
    AuthStepType,
  },
  methods: {
    gotoUserEditPage() {
      this.triggerEvent('gotoUserEditPage');
    },

    login() {
      wx.login({
        timeout: 500,
        //获取code成功
        success: (result) => {
          console.log(">>>>>>>");
          if (result.code) {
            wx.request({
              url: 'http://localhost:8080/login',
              data: {
                code: result.code
              },
              method:'POST',
              header:{ "content-type": "application/json"}
            })
          }
          console.log(result);
        },
        //获取code失败
        fail: (err) => {
          console.log('');
        },
        //最终执行,一般来说应该就是释放资源了
        complete: (res) => {},
      })
    }

  },
});